package com.wili.extract_srcFile.java;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.wili.autoeq.Refs;
import com.wili.c.Class9;
import com.wili.c.Src9;
import com.wili.c.Str9;
public class Coms26 {
	static final String NL = Str9.NL;
	/**
	 * 
	 */
	static void visit_all_simple_staticFinalField_fromImports_and_samePackage(RootOfClsMember root) {
	}
	private static Set<Class<?>> _clsSet1 = new HashSet<>(), _clsSet2 = new HashSet<>();

	private static Set<String> _packageSet = new HashSet<>();
	/**
	 * 	读取类的属性集
	 */
	static void readClassFields(RootOfClsMember root, int fromIndex, int toIndex) {
		Refs.key();
		String fieldHead = root.fileSt0.substring(fromIndex, toIndex);
		List<Object[]> fds = Src9.readFieldRange_asList(root.fileSt, fromIndex, toIndex);
		if (fds.size() > 1)
			fds = Src9.readFieldRange_asList(root.fileSt, fromIndex, toIndex);
		FieldRange[] fields = fds.size() == 1 ? null : new FieldRange[fds.size()];
		for (int i = 0; i < fds.size(); i++) {
			Object[] fd = fds.get(i);
			int start = (Integer) fd[1], end = (Integer) fd[2];
			if (i == 0) {
				//root.fileSt0.substring(fromIndex,fromIndex+100);
				fieldHead = root.fileSt0.substring(fromIndex, start);
				//Ca.pause();
			}
			FieldRange fd2 = new FieldRange(root, fieldHead, (String) fd[0], fromIndex, start, end);
			root.memberRanges.add(fd2);
			if (fields != null) {
				fields[i] = fd2;
				fd2.ranges = fields;
			}
		}
	}

	public static int visitStaticFinalSimpleFields(Class<?> cls) {
		if (cls == null)
			return 0;
		if (cls.isAnonymousClass())
			return 0;
		if (!cls.isInterface() && cls.isMemberClass() && !Modifier.isStatic(cls.getModifiers()))
			return 0;
		RangesOfClsMember memRange = RangesOfClsMember.getInst(-1, cls);
		if (memRange == null || memRange.root == null)
			return 0;
		int times = 0;
		for (ClsRange crange : memRange.root.getClsRangeMap().values()) {
			for (FieldRange frange : crange.fieldMap.values()) {
				if (frange.visited)
					continue;
				if (Class9.isStaticFinalSimpleValue(cls, frange.get())) {
					frange.setVisited();
					++times;
				}
			}
		}
		return times;
	}
}